package com.littleu.yojoincn.controller.tt;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.littleu.yojoincn.common.util.PageUtil;
import com.littleu.yojoincn.dto.item.ItemSkuQueryDTO;
import com.littleu.yojoincn.model.ItemSkuDO;
import com.littleu.yojoincn.service.ItemService;
import com.littleu.yojoincn.vo.PageResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Validated
@RequestMapping("/tt/item")
public class ItemController {
    @Autowired
    private ItemService itemService;

    @PostMapping("/sku/page")
    public PageResponseVO<ItemSkuDO> getItemSkuPaging(@RequestBody @Validated ItemSkuQueryDTO dto){
        IPage<ItemSkuDO> paging = this.itemService.getItemSkuPaging(dto.getPage(), dto.getCount());
        return PageUtil.build(paging);
    }

    @PostMapping("/sku/condition")
    public List<ItemSkuDO> getItemSkuByCondition(@RequestBody @Validated ItemSkuQueryDTO dto){
        return this.itemService.getItemSkuWithoutPage(dto);
    }
}
